package edu.uestc.gene.ui.view;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;

import edu.uestc.gene.ui.controller.ConfigCompositeController;
import edu.uestc.gene.ui.controller.DataCompositeController;
import edu.uestc.gene.ui.util.ShellUtil;

public class Main {

	public static final String LOGO = "/images/uestc.png";

	protected Display display;
	protected Shell shell;

	public Main() {
		display = new Display();
		shell = new Shell(display, SWT.MIN | SWT.CLOSE | SWT.ON_TOP | SWT.MAX);
		config();
	}

	private void config() {
		shell.setBounds(ShellUtil.setLocation(shell, 800, 600));
		shell.setLayout(new GridLayout());
		shell.setImage(ShellUtil.createImage(LOGO));
		shell.setText("生物计算");
		drawFrame();
		shell.open();
		close();
	}

	private void drawFrame() {
		Group up = new Group(shell, 0);
		Group down = new Group(shell, 0);

		down.setLayoutData(ShellUtil.getData2(1, 1));
		down.setText("统计数据");
		down.setLayout(new FillLayout());
		DataCompositeController com = new DataCompositeController(down,
				SWT.BORDER);

		up.setText("配置项");
		up.setLayoutData(ShellUtil.getData1(1, 1));
		up.setLayout(new FillLayout());
		new ConfigCompositeController(com, up, SWT.BORDER);
	}

	private void close() {
		while (!shell.isDisposed())
			if (!display.readAndDispatch())
				display.sleep();
		display.dispose();
	}

	public static void main(String[] args) {
		new Main();
	}
}
